<?php
/*
*代充值佣金
*/
namespace App\Http\Controllers\Admin;

use App\Models\RechargeCommission;
use App\Models\SystemConfig;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class RechargeCommissionController extends Controller
{
    public function index(Request $request)
    {
        $input = $request->all();
        $data  = RechargeCommission::getRechargeCommissionList($input);
        $conf  = SystemConfig::getConfValByConfKey('commission_rate');
        return view('admin.Commission.index',['lists'=>$data,'search'=>$input,'commission_rate_conf'=>$conf]);
    }

    public function edit($rate)
    {
        if (!isset($rate)||!is_numeric($rate)){
            return redirect()->back()->with('danger','输入分佣比例错误');
        }

        $flag = SystemConfig::modifyValByConfKey('commission_rate',$rate);
        if($flag){
            return redirect()->back()->with('success','更新成功');
        }else{
            return redirect()->back()->with('danger','更新失败');
        }
    }
}
